home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Sprite 1984 - 1993
/
Sprite 1984 - 1993.iso
/
src
/
lib
/
c
/
unixSyscall
/
lseek.c
< prev
next >
Wrap
C/C++ Source or Header
|
1988-07-29
|
1KB
|
70 lines
/*
* lseek.c --
*
* Procedure to map from Unix access system call to Sprite.
*
* Copyright 1986 Regents of the University of California
* All rights reserved.
*/
#ifndef lint
static char rcsid[] = "$Header: lseek.c,v 1.4 88/07/29 17:40:26 ouster Exp $ SPRITE (Berkeley)";
#endif not lint
#include <sprite.h>
#include "compatInt.h"
#include <fs.h>
#include <sys/file.h>
#include <errno.h>
/*
*----------------------------------------------------------------------
*
* lseek --
*
* procedure for Unix lseek call.
*
* Results:
* the old offset if the IOC_Reposition call was successful.
* UNIX_ERROR is returned if IOC_Reposition failed.
*
* Side effects:
* None.
*
*----------------------------------------------------------------------
*/
long
lseek(filedes, offset, whence)
int filedes; /* array of stream identifiers */
long offset;
int whence;
{
ReturnStatus status;
int base;
int newOffset;
switch(whence) {
case L_SET:
base = IOC_BASE_ZERO;
break;
case L_INCR:
base = IOC_BASE_CURRENT;
break;
case L_XTND:
base = IOC_BASE_EOF;
break;
default:
errno = EINVAL;
return(UNIX_ERROR);
}
status = Ioc_Reposition(filedes, base, (int) offset, &newOffset);
if (status != SUCCESS) {
errno = Compat_MapCode(status);
return(UNIX_ERROR);
} else {
return(newOffset);
}
}